﻿using lauimini_webform.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lauimini_webform
{
    public partial class edit : System.Web.UI.Page
    {

        int id;
        protected void Page_Load(object sender, EventArgs e)
        {

            id = Convert.ToInt32(Request.QueryString["id"]);
            if (!IsPostBack)
            {
                Title.Text = Request.QueryString["Title"].ToString();
                decription.Text = Request.QueryString["description"].ToString();
                StartTime.Text = Request.QueryString["StartTime"].ToString();
                EndTime.Text = Request.QueryString["EndTime"].ToString();
            }

        }



        protected void Button1_Click(object sender, EventArgs e)
        {
            var result = new UserTargetService().editTarget(id, Title.Text, decription.Text, StartTime.Text, EndTime.Text);
            if (result == -1)
            {
                Response.Write("<script>alert('结束时间不能小于开始时间');</script>");
            }
            if (result != -1)
            {
                Response.Write("<script>alert('修改成功')</script>");
            }
        }
        protected void Button2_Click(object sender, EventArgs e)
        {
            Title.Text = string.Empty;
            decription.Text = string.Empty;
            StartTime.Text = string.Empty;
            EndTime.Text = string.Empty;
        }
        protected void Button3_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/index.aspx");
        }
    }
}